<?php
class App_Tpl_Media extends Mozg_Templator
{
	public function Get(Mozg_Property_Params $obj)
	{
		if ($obj->GetStatus() != App_Source_Media_Status::Ready) return $this->GetThumb($obj);
		
		switch ($obj->GetType())
		{
			case 'photo': return $this->GetPhoto($obj);
			case 'video': return $this->GetVideo($obj);
			case 'audio': return $this->GetAudio($obj);
			default: return '';
		}
	}

	public function GetThumb(Mozg_Property_Params $obj)
	{
        $this->file = $obj;
        $this->folder = $this->GetPhotoThumbFolder('mediaadmin');
        return $this->render('media/_thumb.phtml');
	}
	
	public function GetPhoto(Mozg_Property_Params $obj)
	{
        $this->file = $obj;
        $this->folder = '';//$this->GetPhotoThumbFolder('mediaadmin');
        return $this->render('media/_photo.phtml');
	}
	
	public function GetVideo(Mozg_Property_Params $obj)
	{
        $this->file = $obj;
        $this->mediaFolder = Mozg_Cfg::Get('global/media')->GetMediaImageFolder();
        $this->folder = '';//$this->GetPhotoThumbFolder('mediavideo');
        return $this->render('media/_video.phtml');
	}

	public function GetAudio(Mozg_Property_Params $obj)
	{
        $this->file = $obj;
        $this->mediaFolder = Mozg_Cfg::Get('global/media')->GetMediaImageFolder();
        $this->folder = '';//$this->GetPhotoThumbFolder('mediavideo');
        return $this->render('media/_audio.phtml');
	}

    protected function GetPhotoThumbFolder($thumbFolder)
    {
        return Mozg_Mapper::Get('Image')->GetImageThumbFolder($thumbFolder);
    }
}